
******************************
*                            *
*  NOTES FOR YAKYUU SAIKORO  *
*                            *
******************************

By Dave Hassler, March-April, 2024.
With elements of SOL-20 BASEBALL by 'EAGAN', 11-19-77.
Dice printing routine modified from Apple 1 original by Larry Nelson, 1977.
Some ideas for features inspired by Henri Roca's "Aruba" dice baseball game.

INTRODUCTION

  I have played most of the computer baseball games produced since the early
'80s (I *loved* MicroLeague...), but one of my fondest memories about
baseball simulation games is playing dice baseball in the grade school library on particularly stormy winter afternoons in lieu of going out to
recess.  We started simply enough, but quite quickly the holes in our little
"hit-or-out" games became apparent: way too many home runs, not enough strike
outs, etc.  After we got that ironed out (with help on the math from a
teacher), we had to come up with rules about steals, and baserunning, and
bunting, and pitch type versus swing type (protect/contact/swing away).  It
all got pretty complex.  Charts were involved.  But then came junior high,
and girls (and/or Dungeons and Dragons...hard to remember the order now...),
so the dice game was abandoned.
  But I never forgot about the game, and I never lost my love of baseball,
perhaps because I was not very good at it when I was a kid.  I was *just*
good enough to make a team, but I did not play much in games.  And once
pitchers started throwing curve balls...forget about it!
  Anyway, I totally appreciate how hard it is to hit a round ball with a
round bat, or to hit the cut-off man, or hang onto the ball when some other
kid is barreling down on you from third (yep, I caught; played some third,
some left field).  So, I decided to combine my retro computing hobby with
my love of baseball and recreate my childhood game.

THE PROGRAM

  Written in MITS Altair 680 BASIC 1.1, this program should run, with minor
modification, on any 8- or 16-bit computer that can run a descendant of
the Altair BASIC, such as Commodore BASIC V2, Atari BASIC, Color Computer
BASIC, Applesoft BASIC, GW BASIC, etc.  With a little more work, it will run
under any BASIC interpreter.

  The main considerations are the minimal cursor and screen controls, and the
input method.  Altair BASIC does not have a GET$ input method (as well as
other early Microsoft-produced BASICS such as the first OSI BASIC and
KIM-1 BASIC 9); I think the game would play a little better if the
player only had to make one key press and not have the danger of accidentilly
breaking out of the program.  The only screen controls are 1) clear the screen, 2) 'home' the cursor, and 3) turn on/off reverse video.  In this
game, ANSI terminal 'escape codes' are used; these should be changed to the
native functions in later BASICS.

   Also, Altair BASIC has no built-in provision for seeding the random number
generator from a real-time clock, although it's easy enough to PEEK a PIA or
VIA timer location to get a 0-255 number, or whatever, for a seed value.
My homemade 6802 computer does not have a 6821 PIA, so what I do is this:
  I load the program, but before I run it, I look at the clock on the
computer running my serial terminal emulator and note the minutes and
seconds.  Then, I type in this one-liner in immediate mode
		FOR I=1 TO mmss:F=RND(1):NEXT
and then RUN the game.  That scrambles up the RND just fine.  :^)  Of course,
later BASICs running on later systems have this covered, so convert
accordingly.

GAMEPLAY

  Yakyuu Saikoro (Japanese for 'baseball dice') simulates a baseball game of
one to nine innings.  You play against the computer, taking turns 'rolling' a
pair of six-sided dice to get a result from 2-12; you will 'roll' for the
computer opponent by 'pitching.'  Based on the odds of any given number 
coming up, a baseball play will occur, with events nearly corresponding to
average plays that occured during the 2023 Major League Baseball season
(thanks to baseball-reference.com for season statistics).  The program bats
a little below the league average, but the on-base percentage is a bit
higher, so it all balances out pretty well.

  In addition to rolling dice and seeing the result, you get the opportunity
to steal bases twice each game (the MLB average was 1.7 attempts per game
in 2023).  The computer will attempt to steal only if it is behind and
two-thirds of the game is completed.

PERCENTAGES USED

  The results of the initial dice rolls were set up like this (the 
percentages were obtained from Altair BASIC's random number generator by
'rolling' a pair of dice 10,000 times and getting the frequency):

	Roll	Freq./%  Result   Act. MLB (2023)
	2  	3	 HR	  3.1%
	3  	5	 K	  23.1% *(21% in-game)
	4  	7	 BB	  7.8%
	5  	10	 FO	  22.9% **(19% in-game)
	6  	12	 GO-E	  23.0% ***(23% in-game)
	7  	16	 K	  *
	8  	14	 1B	  13.9%
	9  	11	 GO-DP	  ***
	10  	9	 FO-ADV	  **
	11  	5	 2B	  5.3%
	12  	2	 3B	  0.9% (nothing I can do about that
					with only 11 results...)

  This *should* result in a batting average around .280 and an on-base
percentage of about .320, which is about as close as I could get to MLB 2023
with only 11 results.

  Other factors were also considered against the 2023 MLB season.
	When a hard-hit ground ball occurs, there is a 25 percent possibility
that a 6-4-3/4-6-3 double play will occur if there's a runner on first;
otherwise, the play will result in a fielder's choice with the lead runner
(if there is one) being out (line 930 in program).  This could be made more
realistic to take various baserunning situations into account, but hey --
this is a kid's dice game, yeah?  :^)
	When a deep fly ball is hit, if there's a runner on third a
sacrifice fly is recorded.  If there's a runner on second, there's a 50/50
chance the runner will advance to third, the thinking being that if it's
hit to left field, trying to advance would likely be a bad move (line 960).
	If a ground ball is hit, there is, roughly, a 1.6 percent chance
that the infielder will mess up the play, resulting in an error, and the 
batter will reach first (line 438).  So, this happens maybe once a game.
	If a single is hit and there are already runners on base, there is
a 27-percent chance that the runner will take two bases.  I kind of went with
my gut on that number, so it may need improvement (line 1400).
	For steals, I consulted baseball-reference.com for the stolen base
to caught stealing ratio, and decided on a 75-percent success rate.  You can
also try to steal home, but that's only going to work 25 percent of the
time, which I found surprising.  The computer will not try to steal home.
	
PLAYING AGAINST ANOTHER PERSON WITH ACTUAL DICE

  In some ways, this option is much more fun, and something I like to do on
camping trips, especially.  For "real-life play," each player bats by rolling
the dice until there are three outs recorded, then they are passed to the
other player for batting; no one 'pitches.'  Keep score on paper.
  If you want to use the Yakyuu Saikoro program as a basis for real-life
play, simply add the following rolls to the first roll:

  Groundout 6 - check for a fielding error by rolling again.  If the result
is 2 (snake-eyes), then roll another time. If it's 5, an error occured.
[This might prove tedious in real-life games; maybe just do away with errors
altogether, and assume the players are all Gold Glovers...]
  Groundout 9 - possible double play (DP) or fielder's choice (FC) if a
runner is on first base.  If the second roll is 8 or 9, then a double play
occurs, with the lead runner out, as well as the batter.  Otherwise, it's
a fielder's choice: 1) if bases loaded, runner from third is thrown out at
the plate, 2) if runners on third and first, runner on third holds, and the
runner going to second is out, 3) if runners on first and second, the lead
runner is out at third base.
  Flyout 10 - it's to the deep outfield, so if there is a runner on third
base and there are less than two outs, that runner comes home and scores on
a sacrifice fly.  A runner on second base may advance to third on a second
roll of 5 through 8 (52% chance, see rationale above).
  Single 8 - if runners are on base, they may advance two bases on a second
roll of 6 or 7.

  Stealing.  To steal, declare your intention to steal before rolling the
dice to bat, stating which runner is going to try.  No double steals.  A roll
of 3 through 9 will steal second or third bases, while a roll of 9, 10, or 11
will steal home.  You may wish to set certain limits on the number of steal
attempts different from the computer game, or maybe even none at all!

  Back in "the long, long ago time," some kids used to play this game with baseball cards, weighting the dice rolls against their cardboard heroes' 
statistics.  If you modify the rules to play with baseball cards, all I can
say is get ahold of a Rod Carew card - it will not let you down.

VARIABLE LIST

  In an effort to aid others with tweaking this program to work with other
systems, here is list of variables used, starting at the top of the program
(one could sort this easily with a spreadsheet program):

	ES$	ANSI ESCAPE CODE ESC+[
	CL$	CLEAR SCREEN
	HM$	'HOME' CURSOR
	RV$	TURN ON REVERSE VIDEO
	RO$	TURN OFF REVERSE VIDEO
	S	PLAYER STEAL ATTEMPTS FOR THE GAME
	U	HEXADECS STEAL ATTEMPTS FOR THE GAME
	A$	TOP OF DIE GRAPHIC
	B$	BOTTOM OF DIE GRAPHIC
	I(x,y)	MATRIX OF SCORE BY INNING
	S(x)	SCORE FOR EACH TEAM
	T(x)	x: 1=BATTER, 2-4=BASES OCCUPIED, 5=RUNS SCORED IN INNING
	D(x)	DICE
	T$(x)	WHO IS AT BAT
	TE$(x)	WHO IS WINNER
	I2	NUMBER OF INNINGS TO PLAY
	F	GENERIC RND VARIABLE
	SF	'STEAL FLAG' FOR HEXADECS
	R	GENERIC VARIABLE
	I	GENERIC LOOP VARIABLE
	I3	CURRENT INNING
	H	WHICH TEAM IS CURRENTLY BATTING (1 OR 2)
	O	NUMBER OF OUTS THIS HALF INNING
	FL	HEXADECS STEALING FLAG FOR ONLY 1 TRY PER INNING
	P$	GENERIC VARIABLE TO START THE ROLL
	W	THE TOTAL OF THE TWO-DIE ROLL
	Z	THE NUMBER OF BASES THE DICE ROLL IS WORTH
	X	HOLDER VARIABLE
	J	GENERIC LOOP VARIABLE
	P	STEALING - BASE TO STEAL

CONCLUSION

  I hope you have as much fun playing this (and translating it - let's get
this all over the place!) as I had putting it together.  Feel free to
change anything you want; make it your own.  :^)  The main thing, for me, is
that you share this 150-year-old tradition of playing simulated, "parlor"
baseball with others.  Along with a warm adult beverage, nothing beats it on
a cold winter night, dreaming of spring and green fields.
  The name "HEXADECS" is a holdover from EAGAN's SOL-20 BASIC program.  I
imagine a team of DEC engineers playing "work-up" after a hard day of
designing core memory units...  Maybe name your team OCTALS?
  Meiji Jengu Stadium is Japan's Fenway Park or Wrigley Field -- if you ever
get a chance to see a game there, do.  You won't regret it: those Swallows
fans are crazy!  And say "hi" to Rosie the Beer Lady for me.
  And if you see an old guy at the library or in the park, and he has dice
and a baseball scorecard, it's probably me -- come on over, say "hi", and
let's go nine innings.  :^)
